<?php

// 修改用户信息

require_once $this->website['path']['action'] . '/app/token.php';
$json = array('status' => 'error', 'msg' => 'error', 'data' => []);

$uid = fn_post('uid');
$uname = fn_post('uname');

if ($this->website['class']['db']
	->table('user')
	->where('id=? and visile=1', $uid)
	->count()) {
	$json['msg'] = '用户不存在或已被禁用！';
} elseif ($this->website['class']['db']
		->table('user')
		->where('uname=?', $uname)
		->count()) {
	$json['msg'] = '昵称已存在！';
} else {
	$this->website['class']['db']
		->table('user')
		->field('uname')
		->value($uname)
		->where('id=?', $uid)
		->limit(1)
		->update();
	$json['msg'] = '修改成功!';
	$json['status'] = 'ok';
}

$this->json_encode_encrypt($json);